package com.muyu.user.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.muyu.common.core.web.page.PageQueryModel;
import com.muyu.user.service.SysUserGroupService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.muyu.user.mapper.SysUserGroupMapper;
import com.muyu.user.domain.SysUserGroup;
import com.muyu.user.domain.model.SysUserGroupQueryModel;
import com.muyu.user.domain.model.SysUserGroupPageQueryModel;
import com.muyu.user.domain.model.SysUserGroupSaveModel;
import com.muyu.user.domain.model.SysUserGroupEditModel;

/**
 * 用户分组Service业务层处理
 *
 * @author liuguoqiang
 * @date 2025-09-14
 */
@Slf4j
@Service
public class SysUserGroupServiceImpl extends ServiceImpl<SysUserGroupMapper, SysUserGroup>  implements SysUserGroupService {

    /**
     * 查询用户分组列表
     *
     * @param pageQueryModel 用户分组
     * @return 用户分组
     */
    @Override
    public PageQueryModel<SysUserGroupPageQueryModel> pageQuery(SysUserGroupQueryModel pageQueryModel) {
        LambdaQueryWrapper<SysUserGroup> queryWrapper = new LambdaQueryWrapper<>();
           Page<SysUserGroup> page = this.page(pageQueryModel.buildPage(), queryWrapper);
        return PageQueryModel.of(page).cover(SysUserGroupPageQueryModel::infoBuild);
    }


    /**
     * 查询用户分组列表
     *
     * @param pageQueryModel 用户分组
     * @return 用户分组
     */
    @Override
    public List<SysUserGroup> exportList(SysUserGroup pageQueryModel) {
        LambdaQueryWrapper<SysUserGroup> queryWrapper = new LambdaQueryWrapper<>();
           return this.list(queryWrapper);
    }

    /**
     * 用户分组添加
     *
     * @param saveModel 用户分组
     * @return 用户分组集合
     */
    @Override
    public void save(SysUserGroupSaveModel saveModel){
        this.save(SysUserGroup.saveModelBuild(saveModel));
    }

    /**
     * 用户分组修改
     *
     * @param editModel 用户分组修改模型
     * @return 用户分组集合
     */
    @Override
    public void edit(SysUserGroupEditModel editModel){
        this.updateById(SysUserGroup.editModelBuild(editModel));
    }

    /**
     * 用户分组下拉框查询
     * @return
     */
    @Override
    public List<SysUserGroup> getGroupOptions() {
        return this.list();
    }

}
